package com.cykj.pos.controller.api;

import com.cykj.common.core.domain.AjaxResult;
import com.cykj.pos.domain.BizAdvertising;
import com.cykj.pos.domain.BizAdvertisingType;
import com.cykj.pos.profit.dto.BizAdvertisingDTO;
import com.cykj.pos.service.IBizAdvertisingService;
import com.cykj.pos.service.IBizAdvertisingTypeService;
import lombok.RequiredArgsConstructor;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/pos/api/v2/advertising")
@RequiredArgsConstructor(onConstructor_ = @Autowired)
public class PosV2AppAdvertisingController {

    private final IBizAdvertisingService iBizAdvertisingService;

    private final IBizAdvertisingTypeService iBizAdvertisingTypeService;
    @PostMapping("/getAdvertising")
    public AjaxResult selectAdvertisingList(){
        AjaxResult ajaxResult = AjaxResult.success("获取广告位图片");
        List<BizAdvertisingType> typeList = iBizAdvertisingTypeService.selectAllAdvertisingType();
        int a = 0;
        for (int i=0;i<typeList.size();i++){
            List<BizAdvertisingDTO> list = iBizAdvertisingService.selectAdvertisingList(typeList.get(i));
            if (list==null){
                continue;
            }
            ajaxResult.put("data"+a,list);
            a++;
        }
        return ajaxResult;
    }
}
